﻿

create proc spReportPearlAccountMap
AS
SELECT AccountL14Desc as [Account L14 Desc], Leaf as [Account (Leaf)], LeafDescr as [Account (Leaf) Descr], LineType as [Line Type] 
, (Select distinct '>> Remove ' +
	 substring(
        (
            Select ', ' + p1.SystemGocCode  AS [text()]
            From PearlAccountMapGocException p1
            Where p1.PearlAccountMapId= p2.PearlAccountMapId
            ORDER BY p1.PearlAccountMapId
            For XML PATH ('')
        ), 2, 1000) [Students]
From PearlAccountMapGocException p2 Where PearlAccountMapId = PearlAccountMap.Id) as [Additional Rule]
FROM PearlAccountMap